<template>
    <div>
        center
    </div>
</template>

<script>
export default {
    //同样支持async、await语法
    async beforeRouteEnter(to, from, next) {
        let isAuthenticated = await localStorage.getItem("token");

        if (isAuthenticated) {
            next()
        } else {
            next({ name: "Login" })
        }
    },

    beforeRouteLeave() {
        const select = window.confirm("你确定要离开吗？")
        if (!select) return false
    }
}
</script>